package com.tbit.uqbike.client.service.impl;

import com.tbit.uqbike.client.dao.ter.TerPositionDao;
import com.tbit.uqbike.client.pojo.TerPosition;
import com.tbit.uqbike.client.service.TerPositionService;
import com.tbit.uqbike.client.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("terPositionService")
public class TerPositionServiceImpl implements TerPositionService {
    @Autowired
    private TerPositionDao terPositionDao;

    @Override
    public List<TerPosition> getByMachineNOBatch(List<String> machineNOs) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("machineNOs", StringUtil.getArrayListString(machineNOs));

        return terPositionDao.getByMachineNOBatch(params);
    }

    @Override
    public List<TerPosition> getByArea(Double lo, Double la, Integer radius) {
        Double area = 0.00001D * radius;

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("minLo", lo - area);
        params.put("maxLo", lo + area);
        params.put("minLa", la - area);
        params.put("maxLa", la + area);

        return terPositionDao.getByArea(params);
    }


}  